<?php
		/*include_once('init.php');*/


		

        

        $id=!empty($_GET['id'])?$_GET['id']:'';

		

		if(!empty($_POST)) {


		/*	$stuas=$_POST['stuas'];
			echo $stuas;die;*/

			if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_POST['filed'])) {

        	$where['id']=$_POST['id'];
        	$where['val']=$_POST['val'];
        	$where['filed']=$_POST['filed'];


        	$row=edit('news',$where);
        	
        	echo $row;die;
        			
        };


			if(!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {

        	$id=$_POST['id'];
        	
        	$where['status']=$_POST['status'];
        	/*print_r($_POST['status']);die;*/
			$row=edit('news',$where,$id);

        	echo $row;die;

       /* print_r($row);die;*/
        			
        };
		
			

		$where['title']=$_POST['title'];
		$where['type']=$_POST['type'];

		$text=$_POST['text'];
		$textarea=$_POST['textarea'];
/*		
		$link = mysqli_connect('localhost','root','root','p301');
	
		if (!$link) {
			
			echo '<script>alert("数据库连接错误");history.go(-1);</script>';die;
		}
	
		mysqli_query($link,'set names utf8');*/
	

		$row=edit('news',$where);

        if ($row>0) {
        	echo '<script>alert("添加成功");location.href="index.php?c=news&a=news&admin=1";</script>';

        }else{
        	echo '<script>alert("添加失败");history.go(-1);</script>';die;
        }
    }
		



		$arr=getselectByone('news',"`id`='$id'");
   
   include( VIEW_PATH.$admin.'layst.html');



?>
